package com.cloud.school.bus.teacherhelper.modules.settings;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;

import com.android.support.jhf.handlerui.HandlerToastUI;
import com.android.support.jhf.utils.AppJump;
import com.android.support.jhf.utils.MobileUtils;
import com.cloud.school.bus.teacherhelper.R;
import com.cloud.school.bus.teacherhelper.base.activity.BaseActivity;
import com.cloud.school.bus.teacherhelper.base.view.TitleNavBarView;
import com.cloud.school.bus.teacherhelper.include.Version;
import com.cloud.school.bus.teacherhelper.protocol.ProtocolDef;

/**
 * 关于我们
 * 
 * @author jiahongfei
 * 
 */
public class AboutActivity extends BaseActivity {

	public static final String ABOUT_PHONE = "400-606-3996";
	private static final String ABOUT_MAIL = "service@yunxiaoche.com";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_about);

		init();
	}

	@Override
	protected void init() {

		TextView versionTextView = (TextView) findViewById(R.id.versionTextView);
		versionTextView.setText(Version.versionName.substring(1));

		TextView phoneTextView = (TextView) findViewById(R.id.phoneTextView);
		phoneTextView.setText(ABOUT_PHONE);

		TextView websiteTextView = (TextView) findViewById(R.id.websiteTextView);
		websiteTextView.setText(ProtocolDef.URL_ABOUT_WEBSITE.substring(7));

		setListener();

		setTitleNavBar();
	}

	@Override
	protected void setListener() {

		ViewGroup phoneLayout = (ViewGroup) findViewById(R.id.phoneLayout);
		phoneLayout.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				MobileUtils.callPhoneActivity(mContext, ABOUT_PHONE,
						Intent.ACTION_VIEW);
			}
		});
		ViewGroup websiteLayout = (ViewGroup) findViewById(R.id.websiteLayout);
		websiteLayout.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				AppJump.goBrowser(mContext, ProtocolDef.URL_ABOUT_WEBSITE);
			}
		});
		ViewGroup mailLayout = (ViewGroup) findViewById(R.id.mailLayout);
		mailLayout.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				AppJump.goSendMail(mContext, ABOUT_MAIL, "", "");
			}
		});
		TextView serviceAgreementTextView = (TextView) findViewById(R.id.serviceAgreementTextView);
		serviceAgreementTextView.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				Intent intent = new Intent(mContext,
						PermitProtocolActivity.class);
				intent.putExtra("url", ProtocolDef.URL_PRIVACY);
				startActivity(intent);
			}
		});

	}

	protected void setTitleNavBar() {
		final TitleNavBarView titleNavBarView = (TitleNavBarView) findViewById(R.id.titleNavBarView);
		titleNavBarView.setMessage(getString(R.string.about_us));
		titleNavBarView.setLeftButtonOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				finish();
			}
		});
		titleNavBarView.setRightButtonVisibility(View.INVISIBLE);
	}
}
